﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderSelectList.aspx.cs" Inherits="HQWeb.View.Order.OrderSelectList" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <base target="_self" />
    <title></title>
    <link type="text/css" href="../../Styles/GridViewStyle.css" rel="Stylesheet" />
    <script type="text/javascript">
        function SelectClick(objidvalue) {

            window.opener.document.getElementById("hidOrderID").value = objidvalue;

            //window.opener.execScript("__doPostBack('GetOrder','')", "javascript");
            if (window.opener.document.getElementById("hidRunState").value == '1') {

            } else {
                window.opener.document.getElementById("hidRunState").value = '1';
                if (window.opener.execScript) {
                    window.opener.execScript("__doPostBack('GetOrder','')", "javascript");
                } else {
                    var script = window.opener.document.createElement('script');
                    script.setAttribute('type', 'text/javascript');
                    script.text = "__doPostBack('GetOrder','')";
                    window.opener.document.head.appendChild(script);
                    window.opener.document.head.removeChild(script);
                                }
           //     window.opener.document.getElementById("GetOrder").click();
               // window.opener.IsRuning = '0';
                window.close();
            }
        }

        function On_Edit_ID_GridView(GridViewValue, btnEditServerValue) {
            var gridview = document.getElementById(GridViewValue);
            var btnEditServer = document.getElementById(btnEditServerValue);
            if (gridview.rows.length < 2) {
                alert("请选择订单名称！");
                return;
            }
            var checkValue = document.getElementsByName("checkBoxName");
            var i;
            var chkValue;
            var int_ckBox;
            int_ckBox = SumCheckBox_Old();
            //alert("到"+int_ckBox);
            if (int_ckBox == 0 || int_ckBox > 1) {
                alert("请选择订单名称！");
                return;
            }
            if (checkValue.length > 1) {
                for (i = 0; i < checkValue.length; i++)//gridview.rows.length-2
                {
                    if (checkValue[i].checked) {
                        chkValue = checkValue[i].value;
                        //alert("11得到"+chkValue);
                        document.all("strID").value = i;
                        btnEditServer.click();
                    }
                }
            }
            else {
                chkValue = checkValue[0].value;
                //alert("22得到"+chkValue);
                document.all("strID").value = "0";
                btnEditServer.click();
            }
        }

        // 只有全部选中时“全选”选中
        function singleCheckJs(obj) {
            // alert(obj);
            if (form1.checkBoxName.length) {
                for (var i = 0; i < form1.checkBoxName.length; i++) {
                    //alert(document.form1.checkBoxName[i]);
                    if (form1.checkBoxName[i] == obj) {
                        form1.checkBoxName[i].checked = true;
                    }
                    else {
                        form1.checkBoxName[i].checked = false;
                    }
                }
            }
        }

        /// 08/2/2 ybq
        /// <summary>
        /// 统计页面上有多少个checkBoxName已选相同方法有SumCheckBox(),SumCheckBox
        /// </summary>
        function SumCheckBox_Old() {
            checkLength = document.getElementsByName("checkBoxName");
            var n;
            var m = 0;
            //alert("判断"+checkLength.length);
            if (checkLength.length > 1) {
                //alert("vvvvv"+document.form1.checkBoxName[0].checked);
                for (n = 0; n < checkLength.length; n++) {
                    if (form1.checkBoxName[n].checked) {
                        m = m + 1;
                    }
                }
                return m;
            }
            else if (checkLength.length == 0) {
                return m;
            }
            if (form1.checkBoxName.checked)//
            {
                m++;
            }
            return m;
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server" />
    <ajaxToolkit:AutoCompleteExtender ID="ajaxtitel" runat="server" TargetControlID="textName1" ServicePath="../../Wbserver/GetSmartTips.asmx" 
    ServiceMethod="GetGroomName" MinimumPrefixLength="1" ></ajaxToolkit:AutoCompleteExtender>
    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="texName2" ServicePath="../../Wbserver/GetSmartTips.asmx" 
    ServiceMethod="GetBrideName" MinimumPrefixLength="1" ></ajaxToolkit:AutoCompleteExtender>  
    <div>
        <div>
            庆典类型 &nbsp;&nbsp;<asp:DropDownList runat="server" ID="dropType">
            </asp:DropDownList>
            男方姓名:<asp:TextBox runat="server" ID="textName1"></asp:TextBox>&nbsp;&nbsp; 女方姓名：<asp:TextBox
                runat="server" ID="texName2"></asp:TextBox>&nbsp;&nbsp;<asp:Button ID="btnSearch"
                    runat="server" Text="查询" OnClick="btnSearch_Click" />
            <input id="btnDel" type="button" value="选择" onclick="Javascript:On_Edit_ID_GridView('GridView1','btnDelServer');" />&nbsp;&nbsp;
            <input id="btnClose" type="button" value="关闭" onclick="window.close();" />
            <hr />
        </div>
        <div>
            <asp:GridView ID="GridView1" CssClass="GridViewStyle" runat="server" AutoGenerateColumns="False"
                PageSize="25" Width="100%" AllowPaging="True" CellPadding="4" EmptyDataText="没有数据记录！！"
                OnPageIndexChanging="GridView1_PageIndexChanging" GridLines="None" DataKeyNames="ORDER_ID">
                <Columns>
                    <asp:TemplateField FooterText="" HeaderText="" ItemStyle-Width="5%">
                        <ItemTemplate>
                            <input id="checkboxname" name="checkBoxName" onclick="singleCheckJs(this)" type="checkbox"
                                value='<%# DataBinder.Eval(Container.DataItem, "ORDER_ID")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="GROOM_NAME" HeaderText="男方姓名" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle Width="15%"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="BRIDE_NAME" HeaderText="女方姓名" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle Width="15%"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="OrderDate" HeaderText="服务日期" ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle Width="15%"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="NAME" HeaderText="庆典类型" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle Width="10%"></ItemStyle>
                    </asp:BoundField>
                </Columns>
                <PagerTemplate>
                    <table width="100%">
                        <tr>
                            <td style="text-align: center">
                                第<asp:Label ID="lblPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />页
                                共<asp:Label ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount  %>' />页
                                <asp:LinkButton ID="btnFirst" runat="server" CausesValidation="False" CommandArgument="First"
                                    CommandName="Page" Text="首页" />
                                <asp:LinkButton ID="btnPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
                                    CommandName="Page" Text="上一页" />
                                <asp:LinkButton ID="btnNext" runat="server" CausesValidation="False" CommandArgument="Next"
                                    CommandName="Page" Text="下一页" />
                                <asp:LinkButton ID="btnLast" runat="server" CausesValidation="False" CommandArgument="Last"
                                    CommandName="Page" Text="尾页" />
                                <asp:TextBox ID="txtNewPageIndex" runat="server" Width="28px" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                <asp:LinkButton ID="btnGo" runat="server" CausesValidation="False" CommandArgument="-1"
                                    CommandName="Page" Text="GO" />
                            </td>
                        </tr>
                    </table>
                </PagerTemplate>
                <FooterStyle CssClass="GridViewFooterStyle" />
                <RowStyle CssClass="GridViewRowStyle" />
                <SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
                <PagerStyle CssClass="GridViewPagerStyle" />
                <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
                <HeaderStyle CssClass="GridViewHeaderStyle" />
            </asp:GridView>
        </div>
        <div style="display: none">
            <asp:HiddenField ID="strID" runat="server" />
            <asp:Button ID="btnDelServer" runat="server" Text="删除隐藏" Style="visibility: hidden"
                OnClick="btnDelServer_Click" />
        </div>
    </div>
    </form>
</body>
</html>
